<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="用户id" prop="id">
        <el-input
          v-model="queryParams.userId"
          placeholder="模型id"
          clearable
          size="small"
          style="width: 240px"
          @input="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户邮箱" prop="email">
        <el-input
          v-model="queryParams.email"
          placeholder="用户邮箱"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
        <!-- <el-form-item label="用户手机" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="用户手机"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="Search" size="mini" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <div class="layout-content">
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="
          tableData.filter(
            (data) =>
              !search || data.name.toLowerCase().includes(search.toLowerCase())
          )
        "
        style="width: 100%"
        border
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column
          type="selection"
          width="55"
          class="selection"
          align="center"
        /> -->
        <el-table-column label="用户ID" prop="userId" width="100px" align="center">
        </el-table-column>
        <!-- <el-table-column
          label="创建时间"
          align="center"
          prop="createTime"
          width="180"
        >
          <template #default="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column> -->

        <el-table-column label="用户名" prop="username" width="100px" align="center" />
        <el-table-column label="昵称" prop="displayName" width="100px" align="center" />
         <el-table-column label="邮箱" prop="email" width="200px" align="center" />
             <el-table-column label="手机" prop="phone" width="200px" align="center" />
             <el-table-column label="密码" prop="password" width="200px" align="center" />
         <el-table-column label="创建时间" align="center" prop="createTime"  width="180">
            <template #default="scope">
               <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
         </el-table-column>

            <!-- <el-table-column label="状态" align="center" width="100">
            <template #default="scope">
               <el-switch
                  v-model="scope.row.accountStatus"
                  active-value="1"
                  inactive-value="2"
                  @change="handleStatusChange(scope.row)"
               ></el-switch>
            </template>
         </el-table-column> -->


         
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
          min-width="300px"
        >
          <template #default="scope">
            <el-button
              size="mini"
              type="text"
              icon="Tickets"
              @click="openFollowList(scope.row)"
              >关注列表</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="Paperclip"
              @click="openFanList(scope.row)"
              >粉丝列表</el-button
            >
          </template>
        </el-table-column>

      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.current"
        v-model:limit="queryParams.size"
        @pagination="getList"
      />
    </div>

  </div>
</template>
<script setup name="UserList">
import { listModel, infoModel } from "@/api/model/list";
import { listUser } from "@/api/user/index";
import { ref } from "vue";
const { proxy } = getCurrentInstance();
const search = ref("");
const total = ref("0");
const loading = ref(true);

const router = useRouter();
console.log(router)

// 获取用户的选中
const multipleSelection = ref("");
const queryParams = reactive({
  current: 1,
  size: 10,
  userId: "",
  email:'',
  phone:'',

});



// 用户数据列表
const tableData = ref([]);
// 获取用户数据列表
function getList() {
  loading.value = true;
  listUser(queryParams).then((response) => {
    console.log("response.data", response.data);
    total.value = response.data.total;
    tableData.value = response.data.records;
    loading.value = false;
  });
}



/** 用户状态修改 */
function handleStatusChange(row) {
  console.log(row.accountStatus)
  let text = row.accountStatus === "2" ? "启用" : "停用";
  proxy.$modal.confirm('确认要"' + text + '""' + row.displayName + '"用户吗?').then(function () {
    // return changeRoleStatus(row.userId, row.accountStatus);
  }).then(() => {
    proxy.$modal.msgSuccess(text + "成功");
  }).catch(function () {
    row.accountStatus = row.accountStatus === "1" ? "2" : "1";
  });
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.current = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  getList();
}


/** 分配关注列表 */
function openFollowList(row) {
  console.log(row.userId)
  router.push("/business/user-list/follow/" + row.userId);
    // router.push("/system/role-auth/user/" + 106);
}

 

getList();
</script>
<style lang="scss">
.layout-content {
  .table-bottom {
    position: relative;
    margin-top: 50px;
    .setButton {
      position: absolute;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;

      width: 100px;
      text-align: center;
    }
    .setLikedButton {
      position: absolute;
      top: 0;
      left: 110px;
      display: flex;
      justify-content: center;

      width: 100px;
      text-align: center;
    }
  }
}
.modelInfoDialog {
  position: relative;
  margin-top: -30px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  padding: 30px 0;
  @media screen and (max-width: 1024px) {
    padding: 15px 0;
  }
  li {
    padding: 12px 0;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    justify-content: space-between;
    span,
    strong {
      display: block;
    }
  }
}
.modelShareDialog {
  h5 {
    font-size: 16px;
  }
  .el-row {
    margin-bottom: 15px;
    .img {
      padding: 5px;
      box-sizing: border-box;
      background-color: #fff;
      img {
        max-width: 100%;
        height: auto;
        max-width: 150px;
      }
    }
  }
}
</style>
